package com.haoe.service.impl;

import com.haoe.entity.Order;
import com.haoe.mapper.OrderMapper;
import com.haoe.service.OrderService;
import com.sun.org.apache.xpath.internal.operations.Or;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 80305082
 * @Date: 2021/3/15
 * @Description: 订单service实现类
 */
@Service
@Slf4j
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> selectByCustomerId(Long customerId) {
        return orderMapper.selectByCustomerId(customerId);
    }

    @Override
    public Long saveOrder(Order order) {
        Long orderId = orderMapper.insert(order);
        return orderId;
    }

    @Override
    public Order selectById(Long id) {
        return orderMapper.selectById(id);
    }

    @Override
    public void updateOrder(Long id, Integer status) {
        orderMapper.updateStatusById(id, status);
    }

    @Override
    public Order selectByKeys(Long customerId, Long restaurantId, int status) {
        return orderMapper.selectOrderByKeys(customerId, restaurantId, status);
    }

    @Override
    public List<Order> selectByOrderStatus(Long restaurantId, int status) {
        return orderMapper.selectByRestaurantIdAndStatus(restaurantId, status);
    }

    @Override
    public List<Order> selectByRestaurantIdAndStatus(Long restaurantId, List<Integer> statusList) {
        return orderMapper.selectByRestaurantId(restaurantId, statusList);
    }

    @Override
    public List<Order> selectByCustomerIdAndRestaurantId(Long customerId, Long restaurantId) {
        return orderMapper.selectByIds(customerId, restaurantId);
    }

}
